package com.ruoyi.kindergarten.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.kindergarten.domain.EnvironmentInfo;
import com.ruoyi.kindergarten.service.IEnvironmentInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 环境信息Controller
 * 
 * @author ruoyi
 * @date 2025-10-26
 */
@RestController
@RequestMapping("/kindergarten/environmentInfo")
public class EnvironmentInfoController extends BaseController
{
    @Autowired
    private IEnvironmentInfoService environmentInfoService;

    /**
     * 查询环境信息列表
     */
    @PreAuthorize("@ss.hasPermi('kindergarten:environmentInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(EnvironmentInfo environmentInfo)
    {
        startPage();
        List<EnvironmentInfo> list = environmentInfoService.selectEnvironmentInfoList(environmentInfo);
        return getDataTable(list);
    }

    /**
     * 导出环境信息列表
     */
    @PreAuthorize("@ss.hasPermi('kindergarten:environmentInfo:export')")
    @Log(title = "环境信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EnvironmentInfo environmentInfo)
    {
        List<EnvironmentInfo> list = environmentInfoService.selectEnvironmentInfoList(environmentInfo);
        ExcelUtil<EnvironmentInfo> util = new ExcelUtil<EnvironmentInfo>(EnvironmentInfo.class);
        util.exportExcel(response, list, "环境信息数据");
    }

    /**
     * 获取环境信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('kindergarten:environmentInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(environmentInfoService.selectEnvironmentInfoById(id));
    }

    /**
     * 新增环境信息
     */
    @PreAuthorize("@ss.hasPermi('kindergarten:environmentInfo:add')")
    @Log(title = "环境信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EnvironmentInfo environmentInfo)
    {
        return toAjax(environmentInfoService.insertEnvironmentInfo(environmentInfo));
    }

    /**
     * 修改环境信息
     */
    @PreAuthorize("@ss.hasPermi('kindergarten:environmentInfo:edit')")
    @Log(title = "环境信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EnvironmentInfo environmentInfo)
    {
        return toAjax(environmentInfoService.updateEnvironmentInfo(environmentInfo));
    }

    /**
     * 删除环境信息
     */
    @PreAuthorize("@ss.hasPermi('kindergarten:environmentInfo:remove')")
    @Log(title = "环境信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(environmentInfoService.deleteEnvironmentInfoByIds(ids));
    }
}
